{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">用户名：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="username" value="" name="username" class="form-control" placeholder="请输入用户名">
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">性别：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['sex'])){ $info['sex'] = '1'; }; ?>
							<input name="sex" value="1" type="radio" {if condition="$info.sex eq '1'"}checked{/if} title="男">
							<input name="sex" value="2" type="radio" {if condition="$info.sex eq '2'"}checked{/if} title="女">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">手机号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="mobile" value="" name="mobile" class="form-control" placeholder="请输入手机号">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">邮箱：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="email" value="" name="email" class="form-control" placeholder="请输入邮箱">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">头像：</label>
						<div class="col-sm-6">
							<input type="text" autocomplete="off" id="headimg" value="" {if condition="config('my.img_show_status') eq true"}onmousemove="showBigPic(this.value)" onmouseout="closeimg()"{/if} name="headimg" class="form-control" placeholder="请输入头像">
							<span class="help-block m-b-none headimg_process"></span>
						</div>
						<div class="col-sm-2" style="position:relative; right:30px;">
							<span id="headimg_upload"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">积分：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="amount" value="" name="amount" class="form-control" placeholder="请输入积分">
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = 1; }; ?>
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="开启">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="关闭">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">省市区：</label>
						<div class="distpicker5">
							<div class="col-sm-3">
								<select lay-ignore id="province" class="form-control" data-province="{$info.province}"></select>
							</div>
							<div class="col-sm-3">
								<select lay-ignore id="city" class="form-control" data-city="{$info.city}"></select>
							</div>
							<div class="col-sm-3">
								<select lay-ignore id="district" class="form-control" data-district="{$info.district}"></select>
							</div>
						</div>
					</div>
					<script src="__PUBLIC__/static/js/plugins/shengshiqu/distpicker.data.js"></script>
					<script src="__PUBLIC__/static/js/plugins/shengshiqu/distpicker.js"></script>
					<script src="__PUBLIC__/static/js/plugins/shengshiqu/main.js"></script>
					<div class="form-group">
						<label class="col-sm-2 control-label">标签：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" class="form-control" data-role="tagsinput" id="tag" value="" name="tag"  >
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">密码：</label>
						<div class="col-sm-9">
							<input type="password" id="password" value="" name="password" class="form-control" placeholder="请输入密码">
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<link rel='stylesheet' href='__PUBLIC__/static/js/plugins/tagsinput/tagsinput.css'>
<script src='__PUBLIC__/static/js/plugins/tagsinput/tagsinput.min.js'></script>
<script>
layui.use(['form'],function(){});
uploader('headimg_upload','headimg','image',false,'','{:url("admin/Upload/uploadImages")}');
laydate.render({elem: '#create_time',type: 'datetime',trigger:'click'});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
		username: {
			validators: {
				notEmpty: {
					message: '用户名不能为空'
	 			},
	 		}
	 	},
		mobile: {
			validators: {
				notEmpty: {
					message: '手机号不能为空'
	 			},
				regexp: {
					regexp: /^1[345678]\d{9}$/,
					message: ''
	 			},
	 		}
	 	},
		email: {
			validators: {
				regexp: {
					regexp: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
					message: ''
	 			},
	 		}
	 	},
		amount: {
			validators: {
				regexp: {
					regexp: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
					message: ''
	 			},
	 		}
	 	},
		create_time: {
			validators: {
				notEmpty: {
					message: '创建时间不能为空'
	 			},
	 		}
	 	},
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('member_id').set('username').set('mobile').set('email').set('headimg').set('amount').set('province').set('city').set('district').set('tag').set('create_time').set('password');
};

CodeInfoDlg.add = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	 var sex = $("input[name = 'sex']:checked").val();
	 var status = $("input[name = 'status']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/Member/add", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('sex',sex);
	 ajax.set('status',status);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
